
<?php 
require_once('inc/conn.php');
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    if($user==""){
        echo "<script>alert('账号不能为空!');history.go(-1)</script>";
        exit;
    }elseif(mysql_num_rows(mysql_query("select * FROM admin WHERE user='".$_POST['user']."'"))>0){
            echo "<script>alert('该账号已存在,请换另一个账号!');window.location.href='guanliyuan.php'</script>";
            exit;
        }
        if($pass==""){
            echo "<script>alert('密码不能为空!');</script>";
            exit;
        }
$sql_add="INSERT INTO admin(user,pass)VALUES('".$_POST['user']."','".$_POST['pass']."')";
    mysql_query($sql_add);
    echo "<script>alert('添加成功');window.location.href='guanliyuan_list.php'</script>";
    exit;
    mysql_close($conn);
 ?>